package cn.tedu.spring.life;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

@Scope
@Component
public class Life {
    private String dest;

    public Life() {
        System.out.println("1.实例化");
    }

    @Value("努力学习")
    public void setDest(String dest) {
        this.dest = dest;
        System.out.println("2.属性赋值");
    }
    //生命周期初始化方法
    @PostConstruct
    public void init(){
        System.out.println("3.执行初始化方法");
    }

    //Spring Bean 对象销毁前的执行方法
    @PreDestroy
    public void destroy(){
        System.out.println("5.销毁方法");
    }
}
